import http from '@/utils/request';

interface MyRequestOptions {
	url : string;
	method : 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
	data ?: Record<string, unknown>;
	ticket ?: number;
}

/**
 * @description: export async function login(data:出入数据类型) : Promise<数据返回类型>
 */
export async function login(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/sys/user/login',
		method: 'POST',
		// data: {
		// 	username: data.username,
		// 	// 注意：密码在前端使用JSEncrypt进行RSA加密
		// 	password: data.password,
		// },
		data:data,
		ticket: 0, // 为1带satoken
	};
	return await http.globalRequest(options);
}

export async function logout() : Promise<any> {
	const options = {
		url: '/sys/user/logout',
		method: 'GET',
		ticket: 1, // 为1带satoken
	};
	return await http.globalRequest(options);
}

export async function info(data) : Promise<any> {
	const options = {
		url: '/sys/user/info',
		method: 'GET',
		ticket: 1, // 为1带satoken
		data:data
	};
	return await http.globalRequest(options);
}
/**
 * @description: 权限校验
 */
export async function checkOut() : Promise<any> {
	const options = {
		url: '/sys/user/checkOut',
		method: 'GET',
		ticket: 1, // 为1带satoken
	};
	return await http.globalRequest(options);
}

